package cn.pinyuan.news.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.pinyuan.news.bean.NewsContent;
import cn.pinyuan.news.mapper.NewsContentMapper;
import cn.pinyuan.news.service.NewsContentService;
import cn.pinyuan.news.utils.PageResult;

@Service
public class NewsContentServiceImpl implements NewsContentService {

	@Autowired
	private NewsContentMapper newsContentMapper;
	
	// 返回所有新闻
	public List<NewsContent> getNewsContent() {
		return newsContentMapper.selectByExample(null);
	}

	// 返回分页新闻
	public PageResult getNewsPageContent(Integer pageNum,Integer pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		System.out.println("pageNnm:"+pageNum+"pageSize:"+pageSize);
		Page<NewsContent> page = (Page<NewsContent>) newsContentMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}

}
